home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 May / EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso / earcd / misc / emu / arosdev.lha / AROS / rom / utility / umult64.c < prev    next >
C/C++ Source or Header  |  1997-02-03  |  2KB  |  96 lines

  1. /*
  2.     Copyright (C) 1995-1997 AROS - The Amiga Replacement OS
  3.     $Id: umult64.c,v 1.7 1997/02/03 02:58:32 ldp Exp $
  4.  
  5.     Desc: Unsigned 64-bit product of two 32-bit numbers.
  6.     Lang: english
  7. */
  8. #include "utility_intern.h"
  9.  
  10. /*****************************************************************************
  11.  
  12.     NAME */
  13. #include <proto/utility.h>
  14.  
  15.         AROS_LH2(UQUAD, UMult64,
  16.  
  17. /*  SYNOPSIS */
  18.         AROS_LHA(ULONG, arg1, D0),
  19.         AROS_LHA(ULONG, arg2, D1),
  20.  
  21. /*  LOCATION */
  22.         struct UtilityBase *, UtilityBase, 34, Utility)
  23.  
  24. /*  FUNCTION
  25.         Compute the unsigned 64-bit product of arg1 * arg2.
  26.  
  27.     INPUTS
  28.         arg1, arg2  -   32 bit unsigned numbers.
  29.  
  30.     RESULT
  31.         arg1 * arg2
  32.  
  33.     NOTES
  34.         For m68k assembly programmers, UQUADs are returned in D0:D1 (with
  35.         the high 32 bits in D0.
  36.  
  37.         This function is really only for people programming in
  38.         assembly on real Amigas. Most compilers will be able to do this
  39.         math for you inline.
  40.  
  41.     EXAMPLE
  42.  
  43.     BUGS
  44.  
  45.     SEE ALSO
  46.         SMult32(), UMult32(), SMult64()
  47.  
  48.     INTERNALS
  49.         This may or may not be handled by code in config/$(KERNEL),
  50.         for m68k-native it is...
  51.  
  52.         This is essentially UMult32(), but with the code to calculate
  53.         the product of the high 32 bits of the multiplicands.
  54.  
  55.     HISTORY
  56.         29-10-95    digulla automatically created from
  57.                             utility_lib.fd and clib/utility_protos.h
  58.         18-08-96    iaint   Modified UMult32().
  59.  
  60. *****************************************************************************/
  61. {
  62.     AROS_LIBFUNC_INIT
  63.  
  64.     /* If we have native support for 32 * 32 -> 32, use that. */
  65.     return arg1 * arg2;
  66.  
  67.  
  68. #if 0
  69.     /* This is partially the algoritm that is used, however for a
  70.        more complete version see config/m68k-native/smult64.s
  71.  
  72.        This version has problems with:
  73.         - adding the partial products together
  74.         - setting the value of QUADs
  75.     */
  76.  
  77.     UQUAD product;
  78.     UWORD a0, a1, b0, b1;
  79.     ULONG part_prod;
  80.  
  81.     a1 = (arg1 >> 16) & 0xffff;
  82.     a0 = arg1 & 0xffff;
  83.     b1 = (arg2 >> 16) & 0xffff;
  84.     b0 = arg2 & 0xffff;
  85.  
  86.     part_prod = (a0 * b1) + (a1 * b0);
  87.  
  88.     SET_HIGH32OF64(product, (part_prod >> 16) + (a1 * b1));
  89.     SET_LOW32OF64(product, ((part_prod & 0xFFFF) << 16) + (a0 * b0));
  90.  
  91.     return product;
  92. #endif
  93.  
  94.     AROS_LIBFUNC_EXIT
  95. } /* UMult64 */
  96.